<template>
  <div>
    <div class="product_list">
      <div class="listItem" v-for="(item,index) of props.list"
           :style="{'margin-right': (index + 1) % props.col == 0 ? '0' : '16px'}"
           @click="toDetail(item.offer_id)">
        <div v-if="props.type === '3'" class="topNum"
             :style="{'background-image': index <= 3 ? `url('/src/assets/image/top${index}.png')`: `url('/src/assets/image/top3.png')`}">
          TOP{{ index + 1 }}
        </div>
        <div class="goodsBox">
          <img class="goodsImg" :src="item.first_img" alt="">
          <img v-if="props.type === '1' && item.is_new" class="newIcon" src="/src/assets/image/newBtn.png" alt="">
          <img v-if="item.is_lisk" class="scicon" src="/src/assets/image/scicon.png" alt="">
          <img v-if="!item.is_lisk" class="scicon" src="/src/assets/image/bxh.png" alt="">
          <img class="jxicon" src="/src/assets/image/jx.png" alt="">
        </div>
        <div class="content">
          <div class="goodsTitme multi-line-omit">
            {{ item.subject_trans }}
          </div>
          <div class="tip">
<!--            <el-tag type="warning" style="margin-right: 8px" v-if="item.tag_info_list.tag_name_trans">-->
<!--              {{ item.tag_info_list.tag_name_trans[0] }}-->
<!--            </el-tag>-->
          </div>
          <div class="money" v-if="props.type == '1'">
            {{ item.min_price }} ₽
          </div>
          <div class="inventory">
            Куплено：{{ item.sold_out }}
          </div>
          <div class="btn" v-if="props.type != '2'">
            <img src="/src/assets/image/gwc.png" alt="">
            <div>Покупка</div>
          </div>
          <div class="vipDtn" v-if="props.type == '2'" :class="index % 2 === 0 ? 'vipDtnImg2':'vipDtnImg2' ">
            <div class="vipM1">
              <div class="vipMoney">69.8 ₽</div>
              <div class="text">EЖедневHыецeHЫ</div>
            </div>
            <div class="vipM2">
              <div class="vipMoney">69.8 ₽</div>
              <div class="text">EЖедневHыецeHЫ</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

</template>

<script lang="ts" name="Shopping_list" setup>
import {ref, reactive, defineProps, onMounted} from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const props = defineProps({
  type: {
    type: String,
    default: '1'
  },
  //测试用的
  num: {
    type: Number,
    default: 24
  },
  col: {
    type: Number,
    default: 6
  },
  list: {
    type: Array,
    default: []
  }
})
const state = reactive({})
const toDetail = (topId) => {
  router.push({
    path: '/product_detail',
    query:{
      top:topId
    }
  })
}
onMounted(() => {
  // console.log(scrollListRef)
})

</script>


<style lang="less" scoped>
.multi-line-omit {
  word-break: break-all; // 允许单词内自动换行，如果一个单词很长的话
  text-overflow: ellipsis; // 溢出用省略号显示
  overflow: hidden; // 超出的文本隐藏
  display: -webkit-box; // 作为弹性伸缩盒子模型显示
  -webkit-line-clamp: 2; // 显示的行
  -webkit-box-orient: vertical; // 设置伸缩盒子的子元素排列方式--从上到下垂直排列
}

:deep(.el-tag) {
  font-size: 9px !important;
  height: 20px !important;
}

.product_list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  //cursor: pointer;
  .listItem {
    width: 220px;
    //height: 386px;
    background: #FFFFFF;
    box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.1);
    border-radius: 16px 16px 16px 16px;
    margin-bottom: 16px;
    box-sizing: border-box;
    padding: 5px;
    position: relative;

    .topNum {
      position: absolute;
      width: 60px;
      height: 25px;
      z-index: 9999;
      top: -7px;
      left: 16px;
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      font-family: Segoe UI, Segoe UI;
      font-weight: 600;
      font-size: 14px;
      color: #FFFFFF;
      line-height: 23px;
      text-align: center;
      font-style: normal;
      text-transform: none;
    }

    .content {
      padding: 0 5px;
    }

    .goodsBox {
      width: 210px;
      height: 210px;
      border-radius: 16px;
      overflow: hidden;
      position: relative;

      .goodsImg {
        width: 100%;
      }

      .newIcon {
        position: absolute;
        width: 38px;
        height: 38px;
        top: -1px;
        left: -1px;
        z-index: 5;
      }

      .scicon {
        position: absolute;
        width: 20px;
        height: 20px;
        right: 12px;
        top: 12px;
        z-index: 5;
        cursor: pointer;
      }

      .jxicon {
        position: absolute;
        width: 32px;
        height: 32px;
        right: 8px;
        bottom: 8px;
        z-index: 5;
      }
    }

    .goodsTitme {
      margin-top: 8px;
      font-family: Segoe UI, Segoe UI;
      font-weight: 600;
      font-size: 16px;
      color: #333333;
      line-height: 16px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }

    .tip {
      margin-top: 8px;
      height: 25px;
    }

    .money {
      margin-top: 8px;
      font-family: Segoe UI, Segoe UI;
      font-weight: bold;
      font-size: 24px;
      color: #FA3E59;
      line-height: 24px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }

    .inventory {
      margin-top: 8px;
      margin-bottom: 8px;
      font-family: Segoe UI, Segoe UI;
      font-weight: 600;
      font-size: 12px;
      color: #999999;
      line-height: 12px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }

    .btn {
      cursor: pointer;
      width: 200px;
      height: 34px;
      background: #0070E9;
      border-radius: 12px 12px 12px 12px;
      margin-top: 8px;
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      justify-content: center;

      img {
        width: 20px;
        height: 20px;
        margin-right: 4px;
      }

      font-family: Segoe UI, Segoe UI;
      font-weight: bold;
      font-size: 12px;
      color: #FFFFFF;
      line-height: 12px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }

    .vipDtn {
      //margin-top: 8px;
      width: 200px;
      height: 50px;
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      box-sizing: border-box;
      //padding: 20px 16px;
      display: flex;
      justify-content: space-evenly;
      align-content: center;

      .vipM1 {
        position: relative;
        top: 8px;

        .vipMoney {
          font-family: Segoe UI, Segoe UI;
          font-weight: 600;
          font-size: 15px;
          color: #FA3E59;
          text-align: center;
          font-style: normal;
          text-transform: none;
          line-height: 0.8;
        }

        .text {
          width: 60px;
          font-family: Segoe UI, Segoe UI;
          font-weight: 600;
          font-size: 9px;
          color: #FA3E59;
          text-align: center;
          font-style: normal;
          text-transform: none;
          word-break: break-all;
        }
      }

      .vipM2 {
        position: relative;
        top: 8px;

        .vipMoney {
          font-family: Segoe UI, Segoe UI;
          font-weight: 600;
          font-size: 15px;
          color: #ffffff;
          text-align: center;
          font-style: normal;
          text-transform: none;
          line-height: 0.8;
        }

        .text {
          width: 60px;
          font-family: Segoe UI, Segoe UI;
          font-weight: 600;
          font-size: 8px;
          color: #ffffff;
          text-align: center;
          font-style: normal;
          text-transform: none;
          word-break: break-all;
        }
      }
    }

    .vipDtnImg1 {
      background-image: url('/src/assets/image/vip1.png');
    }

    .vipDtnImg2 {
      background-image: url('/src/assets/image/vip2.png');
    }
  }

}

</style>
<script setup lang="ts">
</script>
